// file.h: interface for the CLFile class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_FILE_H__AC0EE5B7_502F_4B5E_955C_DFD170669443__INCLUDED_)
#define AFX_FILE_H__AC0EE5B7_502F_4B5E_955C_DFD170669443__INCLUDED_

#include "str.h"	// Added by ClassView
#include <stdio.h>
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

class CLFile {
public:
	int write(const CLStr& buf) const;
	int write(LPCSTR buf, int len) const;
	int read(CLStr& buf,int sz=0) const;
	int getline(CLStr& line) const;
	int fprintf(const char* fmt,...) const;
	int eof() const;
	int good() const {	return (m_fp!=NULL); }

	CLFile(LPCSTR filename,LPCSTR mode="a+");
	CLFile(FILE* fp,int close=0){ m_fp=fp; m_mustclose=close; }
	CLFile();
	virtual ~CLFile();

	int open(LPCSTR filename,LPCSTR mode="a+");
	void close();

protected:
	CLStr m_filename;
	FILE* m_fp;
	int   m_mustclose;
};

#endif // !defined(AFX_FILE_H__AC0EE5B7_502F_4B5E_955C_DFD170669443__INCLUDED_)
